/**
 * @author LKQ
 * @date 2021/12/26 9:51
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums = {-1, 0, 3, 5, 9, 12};
        System.out.println(solution.search(nums, 2));
    }

    public int search(int[] nums, int target) {
        int n = nums.length, left = 0, right = n-1;
        while (left < right){
            int mid = left + (right - left) / 2;
            if (target > nums[mid]) {
                left = mid + 1 ;
            }else {
                right = mid;
            }
        }
        return nums[left] == target ? left : -1;
    }
}
